package com.hup.utils.commons.swing;

import java.awt.event.ActionEvent;

/**
 * 实现终止 actionPerformed事件传递功能;
 * actionPerformed的事件是'从后向前(添加的ActionListener)'传递的
 * @author hugan
 * @date 2020/3/22
 */
public class ActionEventUtil {

    private static final Object ABORT_TAG = "ABORT_TAG";

    /**
     * 终止事件传递
     *
     * @apiNote {@link ActionEventUtil#isAborted(ActionEvent)}
     */
    public static void setAbort(ActionEvent e) {
        e.setSource(ABORT_TAG);
    }

    /**
     * 判断事件是否已经终止
     *
     * @apiNote {@link ActionEventUtil#setAbort(ActionEvent)}
     */
    public static boolean isAborted(ActionEvent e) {
        return ABORT_TAG.equals(e.getSource());
    }

}
